package com.wlyuan.open.scanner.domain.order;

import com.wlyuan.open.scanner.dao.entity.OrderContainsDO;
import com.wlyuan.open.scanner.domain.quotation.CombineQuotationSpec;
import com.wlyuan.open.scanner.domain.quotation.QuotationOrder;
import com.wlyuan.open.scanner.utils.mappings.MappingInvalid;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author lijing
 * @description
 */
public class OrderContainConvert {

    private static final Convert CONVERT = Mappers.getMapper(Convert.class);

    @Mapper(uses = MappingInvalid.class)
    public interface Convert {

        @Mappings({
                @Mapping(target = "ownerOrderId", source = "containsOwnerorderid"),
                @Mapping(target = "orderId", source = "containsOrderid"),
                @Mapping(target = "volume", source = "containsVolume"),
                @Mapping(target = "weight", source = "containsWeight"),
                @Mapping(target = "amount", source = "containsAmount"),
                @Mapping(target = "invalid", source = "containsInvalid"),
                @Mapping(target = "comments", source = "containsComments"),
                @Mapping(target = "type", source = "containsOrdertype"),
                @Mapping(target = "id", source = "containsId"),
                @Mapping(target = "creatorAt", source = "containsCreator"),
                @Mapping(target = "createTime", source = "containsInserttime"),
                @Mapping(target = "updaterAt", source = "containsUpdater"),
                @Mapping(target = "updateTime", source = "containsUpdatetime"),
        })
        OrderContain convert(OrderContainsDO source);

        List<OrderContain> convert(List<OrderContainsDO> source);

        @Mappings({
                @Mapping(target = "waybillId", source = "orderId"),
        })
        CombineQuotationSpec convert(QuotationOrder source);
    }

    public static List<OrderContain> convert(List<OrderContainsDO> creation) {
        return CONVERT.convert(creation);
    }

    public static OrderContain convert(OrderContainsDO source) {
        return CONVERT.convert(source);
    }

    public static CombineQuotationSpec convert(QuotationOrder source) {
        return CONVERT.convert(source);
    }
}
